package com.example.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mapper.UserMapper;
import com.example.dto.Register;
import com.example.pojo.applyInfo;
import com.example.pojo.user;
import com.example.service.UserService;
import com.example.utils.Md5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{


    @Autowired
    private UserMapper userMapper;

    @Override
    public user findByUserName(String username) {
        user u = userMapper.findByUserName(username);
        return u;
    }

    @Override
    public void register(Register register) {
        //加密
        String md5String =  Md5Utils.getMd5String(register.getPassword());
        register.password = md5String;
        //添加
        userMapper.add(register);
    }

    @Override
    public void update(user u){
        userMapper.update(u);
    }

    @Override
    public void updatePwd(String pwd,String username){
        userMapper.updatePwd(pwd,username);
    }

    @Override
    public IPage<applyInfo> applyInfo(Page<applyInfo> applyInfoPage,String id){
        return userMapper.applyInfo(applyInfoPage,id);
    }

    @Override
    public void apply(applyInfo a){
        userMapper.apply(a);
    }

}
